 <?php echo $this->load->view('_elements/registratednavigation'); ?>

<div id="content">
    <div id="centerbar">
    <?php if(empty($message_error)):?>
        <div class="titlered"><?php echo $Title;?> - <span id="showedrefferal"><?php echo $ref_id?></span></div>
        <div id="tableblock" class="blockstyle" >
            <table id="requestable">
                <thead>
                    <tr>
                        <th><?php echo $this->user_model->fields['referral_no']?></th>
                        <th><?php echo $this->user_model->fields['ref_status']?></th>
                        <th><?php echo $this->user_model->fields['ref_date_posted']?></th>
                        <th><?php echo $this->user_model->fields['ref_end_date']?></th>
                        <th><?php echo $this->user_model->fields['ref_abstract']?></th>
                        <th><?php echo $this->user_model->fields['ref_ask']?></th>
                        <th><?php echo $this->user_model->fields['ref_bids']?></th>
                        <th><?php echo $this->user_model->fields['ref_avg_bid']?></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><?php echo $ref_id?></td>
                        <td><?php echo $ref_status?></td>
                        <td><?php echo $ref_date_posted?></td>
                        <td><?php echo $ref_end_date?></td>
                        <td><?php echo $ref_abstract?></td>
                        <td><?php echo $ref_ask?></td>
                        <td><?php echo $ref_bids?></td>
                        <td><?php echo $ref_avg_bid?></td>
                    </tr>
                </tbody>
            </table>
            <div style="height:15px;"></div>
            <div class="titlered">Number of Bids (<span id="numberofbids"><?php echo $bids_number; ?></span>)</div>
               <table id="bidstable">
                   <thead>
                       <tr>
                            <th><?php echo $this->user_model->fields['bid_no']?></th>
                            <th><?php echo $this->user_model->fields['bid_date']?></th>
                            <th><?php echo $this->user_model->fields['member_id']?></th>
                            <th><?php echo $this->user_model->fields['response_ex']?></th>
                            <th><?php echo $this->user_model->fields['bid_price']?></th>
                        </tr>
                   </thead>
                   <tbody>
                       <?php foreach($bids as $key => $value) {
                            echo "<tr>
                                    <td>".anchor('/user/bidoptions/'.$ref_id.'/'.$value['ub_ID'], $value['ub_ID'])."</td>
                                    <td>".$value['ub_date']."</td>
                                    <td>".'M'.$value['ub_user_ID']."</td>
                                    <td>".$value['ub_response']."</td>
                                    <td>".$value['ub_price']."</td>
                                 </tr>";
                       }
                       ?>
                        
                   </tbody>
               </table>
        </div>
        <?php else:?>
            <?php echo $message_error;?>
        <?php endif; ?>
    </div>

<?php echo $this->load->view('_elements/Followrefs'); ?>
</div>

<script type="text/javascript">

	var oTable;
	$(document).ready(function()
	{
		/* Init DataTables */
		oTable = $('#bidstable').dataTable(
		{
            "sDom": '<"top"i>rt<"bottom"flp><"clear">',
			"aaSorting": [],
			"aoColumns": [
	  			{ "bSortable": true },
	  			null,
	  			null,
	  			null,
	  			null
	  		],

			"bPaginate": true,
			"bLengthChange": true,
			"bFilter": false,
			"bSort": true,
			"bInfo": false,
			"bAutoWidth": true,
			"bJQueryUI": true,
			"sPaginationType": "full_numbers"
		});

		$('#bidstable_paginate').append('<span id="page_text" class="red fg-button ui-button ui-state-default ui-state-disabled">Page </span>');
    	$('#bidstable_first, #bidstable_previous, #bidstable_next, #bidstable_last').hide();
        $(".dataTables_paginate span span.fg-button.ui-button.ui-state-default").parent().attr('id','leftnavigation');

	});

	/*
	 * I don't actually use this here, but it is provided as it might be useful and demonstrates
	 * getting the TR nodes from DataTables
	 */
	function fnGetSelected( oTableLocal )
	{
		var aReturn = new Array();
		var aTrs = oTableLocal.fnGetNodes();

		for ( var i=0 ; i<aTrs.length ; i++ )
		{
			if ( $(aTrs[i]).hasClass('row_selected') )
			{
				aReturn.push( aTrs[i] );
			}
		}
		return aReturn;
	}


	</script>
